from django.db import models

# Create your models here.
class BOOK(models.Model):
    btitle=models.CharField(max_length=100,verbose_name='书名')
    bpud_date=models.DateField(verbose_name='日期')
    author=models.CharField(max_length=100,verbose_name='作者')
    bimg = models.ImageField(upload_to='imgs/%Y/%m/%d',verbose_name='上传图片',null=True)
    is_delete=models.BooleanField(verbose_name='逻辑删除',default=False)

    class Meta:
        db_table='z-book'
    def __str__(self):
        return f"{self.btitle,self.author}"
class Hero(models.Model):
    hname=models.CharField(max_length=100,verbose_name='英雄')
    bocomment=models.IntegerField(verbose_name='评论量',default=0)
    bread=models.IntegerField(verbose_name='阅读量',default=0)
    hbook=models.ForeignKey(BOOK,on_delete=models.CASCADE,related_name='hero')
    is_delete=models.BooleanField(verbose_name='逻辑删除',default=False)
    class Meta:
        db_table='z-hero'
    def __str__(self):
        return f"{self.hname}"